﻿<?xml version="1.0" encoding="utf-8" ?>
<Feature>
  <BusinessRules>
    <BusinessRule name="validateIpAddressesGeoInfo" security="disabled">
      <Option value="$GeoByteRemoteTier$">
        <RemoteRule url="$GeoByteRemoteTier$" />
        <LocalClass name="GeoByte.GeoByteBizRules,ScsCore" />
      </Option>
    </BusinessRule>
    <BusinessRule name="scheduledCheckForIpAddressGeoInfo" security="disabled">
      <Option value="$GeoByteRemoteTier$">
        <RemoteRule url="$GeoByteRemoteTier$" />
        <LocalClass name="GeoByte.GeoByteBizRules,ScsCore" />
      </Option>
    </BusinessRule>
    <BusinessRule name="getIpAddressGeoInfo" security="disabled">
      <Option value="$GeoByteRemoteTier$">
        <RemoteRule url="$GeoByteRemoteTier$" />
        <LocalClass name="GeoByte.GeoByteBizRules,ScsCore" />
      </Option>
    </BusinessRule>
  </BusinessRules>

  <BusinessRules>
    <BusinessRule name="scheduledCheckForUnvalidatedUserLoginIps" security="disabled">
      <LocalClass name="GeoByte.GeoByteBizRules,ScsCore" />
    </BusinessRule>
  </BusinessRules>
      <!--<BusinessRules>
    <BusinessRule name="getFedexCompanySettingsTemplate" security="disabled" postExtends="getCompanySettingsDisplayTemplate">
      <LocalClass name="Fedex.FedexTemplateBizRules,ScsCore" />
    </BusinessRule>
    <BusinessRule name="getFedexCompanySettingsDbFields" security="disabled" postExtends="getCompanySettingsDbFields">
      <LocalClass name="Fedex.FedexTemplateBizRules,ScsCore" />
    </BusinessRule>
  </BusinessRules>-->

  <BusinessObjects>
    <BusinessObject type="IpAddressGeoInfo" key="ipAddress">
      <Field name="ipAddress" type="String" />
      <Field name="isKnown" type="Boolean" />
      <Field name="iso2" type="String" />
      <Field name="iso3" type="String" />
      <Field name="regionId" type="Integer" />
      <Field name="region" type="String" />
      <Field name="regionCode" type="String" />
      <Field name="cityId" type="Integer" />
      <Field name="city" type="String" />
      <Field name="latitude" type="String" />
      <Field name="longitude" type="String" />
      <Field name="timeZone" type="Integer" />
      <Field name="certainty" type="Integer" />
      <Field name="timeValidated" type="Date" />
    </BusinessObject>

    <BusinessObject type="GeoByteLocalIpRuntimeInfo">
      <Field name="localIP" type="String" />
      <Field name="numChecked" type="Integer" />
    </BusinessObject>

    <BusinessObject type="GeoByteRuntimeInfo">
      <Field name="lastHourWindow" type="Date" />
      <Field name="checks" type="List(GeoByteLocalIpRuntimeInfo)" />
    </BusinessObject>

    <BusinessObject type="GeoByteConfiguration">
      <Field name="userId" type="String" />
      <Field name="password" type="String" />
      <Field name="freePerIp" type="Integer">20</Field>
      <Field name="maxPerHourPerLocalIp" type="Integer" />
      <Field name="localIP" type="String" />  <!-- Comma delimited list of local ip addresses to make requests from. -->
      <Field name="runtime" type="GeoByteRuntimeInfo" />
    </BusinessObject>

    <BusinessObject injects="CompanySettings">
      <Field name="geoByte" type="GeoByteConfiguration"/>
    </BusinessObject>
  </BusinessObjects>
  
  <Scheduler timerInterval="1000">
    <UserTask id="CheckIpGeo" frequency="every 5 min" isSingleton="True">
      <Rule method="scheduledCheckForIpAddressGeoInfo">
        <Params/>
      </Rule>
    </UserTask>
    <UserTask id="CheckUnValId" frequency="every 5 min" isSingleton="True">
      <Rule method="scheduledCheckForUnvalidatedUserLoginIps">
        <Params/>
      </Rule>
    </UserTask>
  </Scheduler>
</Feature>
